#Cleaning Experiment 1 - Offensiveness
#Alan Yan
#3-16-2020

#clear environment
rm(list = ls())

#load libraries
library(pacman)
p_load(tidyverse)

#load data
dt <- read.csv("01-Experiment-1/data/03-post-experiment/raw_data.csv", header = TRUE, stringsAsFactors = FALSE)

#columns for each treatment
dt$male <- ifelse(dt$group == "male", 1, 0)
dt$female <- ifelse(dt$group == "female", 1, 0)
dt$gen.neutral <- ifelse(dt$group == "gen.neutral", 1, 0)
dt$no.name <- ifelse(dt$group == "no.name", 1, 0)

#noncompliance
dt$male.instrument <- ifelse(dt$conversation_status != "start", 
                             dt$male, 0)
dt$female.instrument <- ifelse(dt$conversation_status != "start", 
                               dt$female, 0)
dt$gen.neutral.instrument <- ifelse(dt$conversation_status != "start", 
                                    dt$gen.neutral, 0)
dt$no.name.instrument <- ifelse(dt$conversation_status != "start", 
                                dt$no.name, 0)

#silencing variable
dt$silenced <- ifelse(dt$opted_out == "true", 100, 0)

#attendance variable
dt$attendance <- ifelse(dt$Attend.March.For.Our.Lives == "Yes", 100, 0)

#respondend
dt$responded <- ifelse(dt$num_messages > 1, 100, 0)

#write csv
write.csv(dt, "01-Experiment-1/data/04-clean-data/clean_data.csv")
